home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume18 / parseargs / patch04a next >
Encoding:
Internet Message Format  |  1991-04-25  |  50.9 KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i101:  parseargs - functions to parse command line arguments, Patch04a/4
  4. Message-ID: <1991Apr26.035651.18697@sparky.IMD.Sterling.COM>
  5. Date: 26 Apr 91 03:56:51 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: aa10b441 0172f42d 2638fed9 93182d90
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 18, Issue 101
  11. Archive-name: parseargs/patch04a
  12. Patch-To: parseargs: Volume 17, Issue 45-57
  13.  
  14. This is patch04 for parseargs. It is a four part patch that you will need
  15. to unshar in order.  It fixes some major bugs, a few minor ones, and
  16. corrects some more errors in the documentation. Two new files are given here
  17. (patchlevel.h & doc/effects.inc). Two old files are resubmitted (Makefile &
  18. doc/Makefile) amd two patchfiles are included (PATCH and DOCPATCH).
  19.  
  20.  ______________________ "And miles to go before I sleep." ______________________
  21.  Brad Appleton                         Harris Corp., Computer Systems Division
  22.    Software Engineer                   2101 West Cypress Creek Road,  M/S 161 
  23.      brad@ssd.csd.harris.com           Fort Lauderdale, FL  33309-1892  USA
  24.        ...!uunet!hcx1!brad                 Phone: (305) 973-5360
  25.  ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
  26. #!/bin/sh
  27. # This is a shell archive (produced by shar 3.49)
  28. # To extract the files from this archive, save it to a file, remove
  29. # everything above the "!/bin/sh" line above, and type "sh file_name".
  30. #
  31. # made 04/24/1991 21:50 UTC by kent@sparky.IMD.Sterling.COM
  32. #
  33. # existing files WILL be overwritten
  34. #
  35. # This is part 1 of a multipart archive                                    
  36. # do not concatenate these parts, unpack them in order with /bin/sh        
  37. #
  38. # This shar contains:
  39. # length  mode       name
  40. # ------ ---------- ------------------------------------------
  41. #  66103 -rw-rw-r-- DOCPATCH
  42. #   4610 -rw-rw-r-- Makefile
  43. #  79034 -rw-rw-r-- PATCH
  44. #   2667 -rw-rw-r-- doc/Makefile
  45. #   1060 -rw-rw-r-- doc/effects.inc
  46. #   2409 -rw-rw-r-- patchlevel.h
  47. #
  48. if test -r _shar_seq_.tmp; then
  49.     echo 'Must unpack archives in sequence!'
  50.     echo Please unpack part `cat _shar_seq_.tmp` next
  51.     exit 1
  52. fi
  53. # ============= DOCPATCH ==============
  54. echo 'x - extracting DOCPATCH (Text)'
  55. sed 's/^X//' << 'SHAR_EOF' > 'DOCPATCH' &&
  56. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/argtype3.txt    Wed Apr 10 09:55:51 1991
  57. --- argtype3.txt    Mon Apr 15 08:31:00 1991
  58. ***************
  59. *** 42,51 ****
  60. X       called when an argument of    that particular    type is    matched
  61. X       by    one of the argument parsing function in    parseargs(3).
  62. X       When such an argument is matched, its argument translation
  63. !      routines is invoked and is    passed (1) the address of the
  64. X       argument descriptor for the matched argument, (2) the possi-
  65. X       ble argument string for that matched argument, and    (3) a
  66. !      boolean filed that    is TRUE    only if    the second parameter
  67. X       points to temporary storage (indicating that some copying
  68. X       may need to be done instead of just pointing to the same
  69. X       object).
  70. --- 42,51 ----
  71. X       called when an argument of    that particular    type is    matched
  72. X       by    one of the argument parsing function in    parseargs(3).
  73. X       When such an argument is matched, its argument translation
  74. !      routine is    invoked    and is passed (1) the address of the
  75. X       argument descriptor for the matched argument, (2) the possi-
  76. X       ble argument string for that matched argument, and    (3) a
  77. !      boolean field that    is TRUE    only if    the second parameter
  78. X       points to temporary storage (indicating that some copying
  79. X       may need to be done instead of just pointing to the same
  80. X       object).
  81. ***************
  82. *** 229,235 ****
  83. X       followed by the type of the items in the vector.
  84. X  
  85. X  SEE ALSO
  86. !      parseargs(3), parseargs(3), parsecntl(1),
  87. X  
  88. X  
  89. X  
  90. --- 229,235 ----
  91. X       followed by the type of the items in the vector.
  92. X  
  93. X  SEE ALSO
  94. !      parseargs(3), parseargs(1), parsecntl(3)
  95. X  
  96. X  
  97. X  
  98. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parseargs1.txt    Wed Apr 10 09:55:52 1991
  99. --- parseargs1.txt    Mon Apr 15 08:31:18 1991
  100. ***************
  101. *** 9,19 ****
  102. X       parseargs - parse command line arguments in shell scripts
  103. X  
  104. X  SYNOPSIS
  105. !      parseargs     [-U] [-M] [-T string] [-F string] [-A]    [-a arg-
  106. !          spec] [-e name] [-f file] [-l]    [-o] [-s shell]
  107. !          [-u] [-i] [-p]    -- name    [arguments ...]
  108. X  
  109. X  OPTIONS
  110. X       -U           just    print program usage, do    not parse the
  111. X             command line
  112. X  
  113. --- 9,22 ----
  114. X       parseargs - parse command line arguments in shell scripts
  115. X  
  116. X  SYNOPSIS
  117. !      parseargs     [-#UMCAlouip1]    [-S separator] [-T string]
  118. !          [-F string] [-a arg-spec] [-e name] [-f file]
  119. !          [-s shell] -- name [arguments ...]
  120. X  
  121. X  OPTIONS
  122. +      -#           just    print the version and patchlevel, do not
  123. +            parse the command line
  124. X       -U           just    print program usage, do    not parse the
  125. X             command line
  126. X  
  127. ***************
  128. *** 20,25 ****
  129. --- 23,31 ----
  130. X       -M           just    print (n|t)roff    -man manual page
  131. X             template, do    not parse the command line
  132. X  
  133. +      -S    separator  field-separator-string used to delimit array
  134. +            elements  (default=
  135. X       -T    string       string to use for true boolean arguments
  136. X             (default=``TRUE'')
  137. X  
  138. ***************
  139. *** 26,31 ****
  140. --- 32,40 ----
  141. X       -F    string       string to use for false boolean arguments
  142. X             (default=``'')
  143. X  
  144. +      -C           Ignore the difference between upper and lower
  145. +            case    when parsing single character options.
  146. X       -A           modify array    behavior for the specified shell.
  147. X  
  148. X       -a    arg-spec   argument specification string
  149. ***************
  150. *** 48,76 ****
  151. X  
  152. X       -p           prompt the user for missing required    arguments
  153. X  
  154. -      -i           ignore bad command-line syntax and continue
  155. -            processing (instead of aborting)
  156. X  
  157. - ARGUMENTS
  158. -      --           Indicates that any remaining    options    are
  159. -            intended for    the calling program.
  160. X  
  161. -      name       name    of calling program
  162. X  
  163. X  
  164. X  
  165. X  
  166. - Page 1
  167. X  
  168. X  
  169. X  
  170. X  
  171. X  
  172. X  
  173. ! PARSEARGS(1)                         PARSEARGS(1)
  174. X  
  175. X  
  176. X  
  177. X       arguments       arguments to    calling    program
  178. X  
  179. X  DESCRIPTION
  180. --- 57,89 ----
  181. X  
  182. X       -p           prompt the user for missing required    arguments
  183. X  
  184. X  
  185. X  
  186. X  
  187. + Page 1
  188. X  
  189. X  
  190. X  
  191. X  
  192. X  
  193. X  
  194. + PARSEARGS(1)                         PARSEARGS(1)
  195. X  
  196. X  
  197. X  
  198. !      -i           ignore bad command-line syntax and continue
  199. !            processing (instead of aborting)
  200. X  
  201. +      -1           Force any and all non-positional parameters to
  202. +            be specified    before any positional parameters
  203. +            on the command-line.
  204. X  
  205. + ARGUMENTS
  206. +      --           Indicates that any remaining    options    are
  207. +            intended for    the calling program.
  208. X  
  209. +      name       name    of calling program
  210. X       arguments       arguments to    calling    program
  211. X  
  212. X  DESCRIPTION
  213. ***************
  214. *** 98,131 ****
  215. X       on    standard output    that is    suitable for input to nroff or
  216. X       troff using the -man macro    package.
  217. X  
  218. X       The argument specification    string contains    one entry for
  219. !      each possible flag.  Entries in the arguments specification
  220. X       string are    separated by commas.  Each entry has five comma-
  221. X       separated fields:    a name,    some flags, a type, a variable-
  222. X       name, and a prompt.  Each of these    fields are described
  223. X       below:
  224. X  
  225. -      name      The single character name of the    associated flag.
  226. -            For example, to indicate    that the program is
  227. -            expecting a ``-x'' flag,    this field would contain
  228. -            'x'.  Positional    arguments (those without a ``-x''
  229. -            prefix) are indicated by    passing    a ``space''
  230. -            character.
  231. X  
  232. -      flags     Flags modifying the semantics of    this entry.
  233. -            These should have one of    ARGREQ to indicate a
  234. -            required    argument or ARGOPT to indicate an
  235. -            optional    argument (ARGOPT is the    default    unless
  236. -            ARGREQ is specified).  ARGPOS can be ``ored'' in
  237. -            to indicate a positional    argument that may also be
  238. -            keyword matched.     ARGNOVAL can be ``ored'' in to
  239. -            indicate    that an    argument is an option or a
  240. -            keyword that does not use an accompanying argument
  241. -            (such as    a boolean flag). This flag is only
  242. -            required    for corresponding argument types that are
  243. X  
  244. X  
  245. X  Page 2
  246. X  
  247. X  
  248. --- 111,131 ----
  249. X       on    standard output    that is    suitable for input to nroff or
  250. X       troff using the -man macro    package.
  251. X  
  252. +      Given no other arguments parseargs    -# prints on standard
  253. +      output, the current version and patchlevel    of the running
  254. +      version of    parseargs.
  255. X       The argument specification    string contains    one entry for
  256. !      each possible flag.  Entries in the argument specification
  257. X       string are    separated by commas.  Each entry has five comma-
  258. X       separated fields:    a name,    some flags, a type, a variable-
  259. X       name, and a prompt.  Each of these    fields are described
  260. X       below:
  261. X  
  262. X  
  263. X  
  264. X  
  265. X  Page 2
  266. X  
  267. X  
  268. ***************
  269. *** 137,154 ****
  270. X  
  271. X  
  272. X  
  273. !            implemented by the programmer; parseargs    already
  274. !            knows which pre-defined argument    types take an
  275. !            argument.  ARGVALOPT can    be ``ored'' in to
  276. X             indicate    that an    argument to the    option may be
  277. X             optionally supplied on the command-line,    but is
  278. !            not required.  ARGVALREQ    can be ``ored''    in to
  279. X             indicate    that an    argument to the    option is
  280. X             required    (this is the default behavior for options
  281. !            that take arguments).  ARGLIST can be ``ored'' in
  282. X             (using the `|' character) to indicate that an
  283. X             argument    is actually a list of one or more
  284. !            arguments from the command line.     ARGHIDDEN can be
  285. X             ``ored''    in to indicate a flag that should not be
  286. X             printed in usage    messages - for example,    flags
  287. X             intended    for internal debugging purposes.
  288. --- 137,165 ----
  289. X  
  290. X  
  291. X  
  292. !      name      The single character name of the    associated flag.
  293. !            For example, to indicate    that the program is
  294. !            expecting a ``-x'' flag,    this field would contain
  295. !            'x'.  Positional    arguments (those without a ``-x''
  296. !            prefix) are indicated by    passing    a ``space''
  297. !            character.
  298. !      flags     Flags modifying the semantics of    this entry.
  299. !            These should have one of    ARGREQ to indicate a
  300. !            required    argument or ARGOPT to indicate an
  301. !            optional    argument (ARGOPT is the    default    unless
  302. !            ARGREQ is specified).  ARGPOS may be ``ored'' in
  303. !            to indicate a positional    argument that may also be
  304. !            keyword matched.     ARGVALOPT may be ``ored'' in to
  305. X             indicate    that an    argument to the    option may be
  306. X             optionally supplied on the command-line,    but is
  307. !            not required.  ARGVALREQ    may be ``ored''    in to
  308. X             indicate    that an    argument to the    option is
  309. X             required    (this is the default behavior for options
  310. !            that take arguments).  ARGLIST may be ``ored'' in
  311. X             (using the `|' character) to indicate that an
  312. X             argument    is actually a list of one or more
  313. !            arguments from the command line.     ARGHIDDEN may be
  314. X             ``ored''    in to indicate a flag that should not be
  315. X             printed in usage    messages - for example,    flags
  316. X             intended    for internal debugging purposes.
  317. ***************
  318. *** 177,194 ****
  319. X       The argument specification    string must be terminated by the
  320. X       single string:  ``ENDOFARGS''.
  321. X  
  322. -      Note that the comma character (',') is used to separate all
  323. -      fields within an entry, and to separate the entries
  324. -      themselves.  For this reason, no field in any entry may
  325. -      contain a comma unless it appears inside of double    or single
  326. -      quotes.
  327. X  
  328. -      Parseargs will parse all command-line arguments for the
  329. -      calling script and    match them against the argument
  330. -      specification string provided. The    argument specification
  331. -      string is read from standard input    by default but may not
  332. -      come from a terminal. The argument    specification string may
  333. -      be    supplied as a single string argument by    using the -a
  334. X  
  335. X  
  336. X  
  337. --- 188,194 ----
  338. ***************
  339. *** 203,208 ****
  340. --- 203,220 ----
  341. X  
  342. X  
  343. X  
  344. +      Note that the comma character (',') is used to separate all
  345. +      fields within an entry, and to separate the entries
  346. +      themselves.  For this reason, no field in any entry may
  347. +      contain a comma unless it appears inside of double    or single
  348. +      quotes.
  349. +      Parseargs will parse all command-line arguments for the
  350. +      calling script and    match them against the argument
  351. +      specification string provided. The    argument specification
  352. +      string is read from standard input    by default but may not
  353. +      come from a terminal. The argument    specification string may
  354. +      be    supplied as a single string argument by    using the -a
  355. X       ``string''    flag.  Long argument specification strings
  356. X       however, may limit    the number of arguments    to the script if
  357. X       there is a    limit to the number of arguments and/or
  358. ***************
  359. *** 244,263 ****
  360. X       string option.  The same may also be done for a boolean flag
  361. X       that is false using the -F    string option.
  362. X  
  363. -      Parseargs will only set the values    of variables that
  364. -      correspond    to arguments that were given on    the command line.
  365. -      If    a particular argument was not supplied on the command
  366. -      line, then    no assignment is made for the corresponding shell
  367. -      variable and it will have the same    value that it had before
  368. -      parseargs was invoked. The    only exception to this is that if
  369. -      the -u option is specified, then the positional parameters
  370. -      are unset before any shell    variable assignments (which may
  371. -      reset the positional parameters) are made.
  372. X  
  373. X  
  374. X  Page 4
  375. X  
  376. X  
  377. --- 256,263 ----
  378. ***************
  379. *** 269,274 ****
  380. --- 269,284 ----
  381. X  
  382. X  
  383. X  
  384. +      Parseargs will only set the values    of variables that
  385. +      correspond    to arguments that were given on    the command line.
  386. +      If    a particular argument was not supplied on the command
  387. +      line, then    no assignment is made for the corresponding shell
  388. +      variable and it will have the same    value that it had before
  389. +      parseargs was invoked. The    only exception to this is that if
  390. +      the -u option is specified, then the positional parameters
  391. +      are unset before any shell    variable assignments (which may
  392. +      reset the positional parameters) are made.
  393. X       The double-dash (``--'') which precedes the name and
  394. X       arguments of the calling program is needed    in order for
  395. X       parseargs to be able to distinguish options to itself from
  396. ***************
  397. *** 280,285 ****
  398. --- 290,310 ----
  399. X       options) are to be    permitted by specifying    the -o (-l)
  400. X       option on the command-line.
  401. X  
  402. + SPECIFYING PARSE-BEHAVIOR
  403. +      The -C, -p, -i, and -1 switches may be used to modify the
  404. +      command-line parsing behavior of the invoking script.
  405. +      Specifying    -C will    cause case-differences in single-
  406. +      character options to be ignored. Specifying -p will cause
  407. +      the user to be interactively prompted for any missing
  408. +      required arguments. Specifying -i will cause syntactically
  409. +      incorrect arguments to be ignored (instead    of having a usage
  410. +      message printed and execution terminated).    Specifying -1
  411. +      will force    all non-positional parameters to precede any
  412. +      positional    parameters on the command-line (hence anything on
  413. +      the command-line after a positional parameter that    resembles
  414. +      a keyword parameter will nevertheles be interpreted as a
  415. +      positional    parameter).
  416. X  OPTIONS    WITH OPTIONAL ARGUMENTS
  417. X       Options that may take an optional argument    need special
  418. X       consideration.  The shell programmer needs    to know    whether
  419. ***************
  420. *** 297,302 ****
  421. --- 322,340 ----
  422. X       the shell variable    associated with    the option in the
  423. X       argument description string.
  424. X  
  425. + Page 5
  426. + PARSEARGS(1)                         PARSEARGS(1)
  427. X  ARGUMENT LISTS
  428. X       Parseargs treats ARGLIST arguments    in a special way. The
  429. X       method used for setting up    an argument list depends largely
  430. ***************
  431. *** 321,340 ****
  432. X       positional    parameters of the calling program will be re-
  433. X       assigned to the contents of the argument list.
  434. X  
  435. - Page 5
  436. - PARSEARGS(1)                         PARSEARGS(1)
  437. X       For the Plan 9 shell (rc),    if the variable    name
  438. X       corresponding to the ARGLIST argument is ``*'', then the
  439. X       positional    parameters of the calling program will be re-
  440. --- 359,364 ----
  441. ***************
  442. *** 344,349 ****
  443. --- 368,374 ----
  444. X       ARGLIST argument is ``ARGV'', then    the positional parameters
  445. X       of    the calling program will be re-assigned    to the contents
  446. X       of    the argument list.
  447. X       Bourne Shell Argument Lists
  448. X  
  449. X       For the Bourne shell, if the associated variable name is NOT
  450. ***************
  451. *** 356,362 ****
  452. X       contains an IFS character (such as    a space    or a tab), then
  453. X       that particular word will be treated by the Bourne    shell as
  454. X       two distinct words.
  455. X       Also for the Bourne shell,    If the associated variable name
  456. X       is    NOT ``--'' and the -A option WAS specified, then that
  457. X       variable is treated as the    root name of an    array that is set
  458. --- 381,386 ----
  459. ***************
  460. *** 363,368 ****
  461. --- 387,406 ----
  462. X       using the following syntax:
  463. X        name1='arg1'
  464. X        name2='arg2'
  465. + Page 6
  466. + PARSEARGS(1)                         PARSEARGS(1)
  467. X            ...
  468. X       and the variable ``name_count'' will be set to contain the
  469. X       number of items in    the array.  The    user may then step
  470. ***************
  471. *** 387,406 ****
  472. X       overwritten by the    set command).
  473. X       It    should be noted    that there is a    bug in versions    of the
  474. X       Korn shell    earlier    than 11/16/88a,    in which the following:
  475. - Page 6
  476. - PARSEARGS(1)                         PARSEARGS(1)
  477. X        set  -A  name     'arg1'     'arg2'     ...
  478. X       causes the    positional parameters to be overwritten    as an
  479. X       unintentional side-effect.    If your    version    of the Korn shell
  480. --- 425,430 ----
  481. ***************
  482. *** 409,414 ****
  483. --- 433,439 ----
  484. X       must save them yourself before you    call parseargs.    This may
  485. X       be    accomplished by    the following:
  486. X        set  -A  save_parms  "$@"
  487. X       C and TC Shell Argument Lists
  488. X  
  489. X       For the C and TC shells, ARGLIST variables    are treated as
  490. ***************
  491. *** 418,436 ****
  492. X       in    $name[2], etc ..., and all items may be    given by $name.
  493. X       Notice that Korn shell arrays start at index zero whereas C
  494. X       and TC shell word-lists start at index one.
  495. X       Bourne-Again Shell    Argument Lists
  496. X  
  497. X       At    present, the Free Software Foundation's    Bourne-Again
  498. X       shell is treated exactly the same as the Bourne Shell. This
  499. X       will change when bash supports arrays.
  500. X       Plan 9 Shell Argument Lists
  501. X  
  502. X       For the Plan 9 shell, if the associated variable name is not
  503. !      ``*'' then    it is considered to be word-list and set using
  504. X       the following syntax:
  505. X        name=( 'arg1'     'arg2'     ... )
  506. X       Awk Argument Lists
  507. X       For awk, if the -A    option is not given, then the output for
  508. X       thes variable-list    will be    a line with the    variable name,
  509. --- 443,474 ----
  510. X       in    $name[2], etc ..., and all items may be    given by $name.
  511. X       Notice that Korn shell arrays start at index zero whereas C
  512. X       and TC shell word-lists start at index one.
  513. X       Bourne-Again Shell    Argument Lists
  514. X  
  515. X       At    present, the Free Software Foundation's    Bourne-Again
  516. X       shell is treated exactly the same as the Bourne Shell. This
  517. X       will change when bash supports arrays.
  518. X       Plan 9 Shell Argument Lists
  519. X  
  520. X       For the Plan 9 shell, if the associated variable name is not
  521. !      ``*'' then    it is considered to be a word-list and set using
  522. ! Page 7
  523. ! PARSEARGS(1)                         PARSEARGS(1)
  524. X       the following syntax:
  525. X        name=( 'arg1'     'arg2'     ... )
  526. X       Awk Argument Lists
  527. X       For awk, if the -A    option is not given, then the output for
  528. X       thes variable-list    will be    a line with the    variable name,
  529. ***************
  530. *** 442,448 ****
  531. X       If    the -A option is given,    then the associated variable is
  532. X       considered    the root name of an array. The ouput for the
  533. X       array will    consist    of two lines for each item in the list
  534. !      (as in the    following expample):
  535. X        name1
  536. X        arg1
  537. X  
  538. --- 480,486 ----
  539. X       If    the -A option is given,    then the associated variable is
  540. X       considered    the root name of an array. The ouput for the
  541. X       array will    consist    of two lines for each item in the list
  542. !      (as in the    following example):
  543. X        name1
  544. X        arg1
  545. X  
  546. ***************
  547. *** 452,477 ****
  548. X       and the variable ``name_count'' will have an output line
  549. X       showing the number    of items in the    array.
  550. X  
  551. - Page 7
  552. - PARSEARGS(1)                         PARSEARGS(1)
  553. X       Perl Argument Lists
  554. X  
  555. X       For perl, each argument list is considered    an array and is
  556. X       set using the following syntax:
  557. !       @name=( arg1 , arg2 ,     ... );
  558. X       A Final Note on Argument Lists
  559. X  
  560. X       The word-lists used by the    C shell, the arrays used by the
  561. --- 490,501 ----
  562. X       and the variable ``name_count'' will have an output line
  563. X       showing the number    of items in the    array.
  564. X  
  565. X       Perl Argument Lists
  566. X  
  567. X       For perl, each argument list is considered    an array and is
  568. X       set using the following syntax:
  569. !       @name=( 'arg1' , 'arg2' ,  ... );
  570. X       A Final Note on Argument Lists
  571. X  
  572. X       The word-lists used by the    C shell, the arrays used by the
  573. ***************
  574. *** 495,500 ****
  575. --- 519,538 ----
  576. X       ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
  577. X       from the command-line if they are selected).
  578. X  
  579. + Page 8
  580. + PARSEARGS(1)                         PARSEARGS(1)
  581. X       It    is important to    note that the contents of the
  582. X       ``CMD_ARGS'' environment variable are NOT expanded    by the
  583. X       shell and hence any special characters (such as quotes or
  584. ***************
  585. *** 519,538 ****
  586. X       of    parsecntl(3).  The user    may set    his (or    her) own desired
  587. X       parsing behavior through the use of the ``PARSECNTL''
  588. X       environment variable.  By indicating any number of    flags
  589. - Page 8
  590. - PARSEARGS(1)                         PARSEARGS(1)
  591. X       (possibly negated)    the user will directly modify the
  592. X       behavior of the parseargs library.    Flags may be combined by
  593. X       placing a `+' or `|' character in between flags. A    switch is
  594. --- 557,562 ----
  595. ***************
  596. *** 551,570 ****
  597. X       Ignore
  598. X        Ignore any unrecognized or improperly    specified
  599. X        command-line arguments and continue execution    of the
  600. !       program. Normally, if    an argument is unmatched (or is
  601. !       improperly specified), a usage message is printed and
  602. !       program execution is terminated.
  603. X  
  604. X       OptsOnly
  605. X        Under    UNIX, setting this flag    will disable the parsing
  606. X        of long-option syntax. This will cause all arguments
  607. !       starting with    '+' to always be treated as a positional
  608. X        parameter (instead of    a long-option).
  609. X  
  610. X       KwdsOnly
  611. X        Under    UNIX, setting this flag    disables the parsing of
  612. X        single-character options.  This will cause all
  613. !       arguments starting with '-' to always    be treated as a
  614. X        positional parameter (instead    of an option).
  615. X  
  616. X       LoptsOnly
  617. --- 575,608 ----
  618. X       Ignore
  619. X        Ignore any unrecognized or improperly    specified
  620. X        command-line arguments and continue execution    of the
  621. !       program. Normally, if    a required argument is unmatched
  622. !       (or an argument is improperly    specified), a usage
  623. !       message is printed program execution is terminated.
  624. X  
  625. X       OptsOnly
  626. X        Under    UNIX, setting this flag    will disable the parsing
  627. X        of long-option syntax. This will cause all arguments
  628. !       starting with    `+' to always be treated as a positional
  629. X        parameter (instead of    a long-option).
  630. X  
  631. + Page 9
  632. + PARSEARGS(1)                         PARSEARGS(1)
  633. X       KwdsOnly
  634. X        Under    UNIX, setting this flag    disables the parsing of
  635. X        single-character options.  This will cause all
  636. !       arguments starting with `-' to always    be treated as a
  637. X        positional parameter (instead    of an option).
  638. X  
  639. X       LoptsOnly
  640. ***************
  641. *** 585,609 ****
  642. X        one positional argument.
  643. X  
  644. X       CaseIgnore
  645. X  
  646. - Page 9
  647. - PARSEARGS(1)                         PARSEARGS(1)
  648. -       Setting this flag causes character-case to be    ignored
  649. -       when attempting to match single-character argument
  650. -       names    (i.e. causes "-i" and "-I" will    be considered
  651. -       equivalent).
  652. X       If    the environment    variable ``PARSECNTL'' is empty    or
  653. X       undefined,    then the parsing behavior set by the programmer
  654. X       is    used.  If the programmer has not explicitly used
  655. --- 623,633 ----
  656. X        one positional argument.
  657. X  
  658. X       CaseIgnore
  659. +       Setting this flag will cause character-case to be
  660. +       ignored when attempting to match single-character
  661. +       argument names (i.e. causes "-i" and "-I" to be
  662. +       considered equivalent).
  663. X  
  664. X       If    the environment    variable ``PARSECNTL'' is empty    or
  665. X       undefined,    then the parsing behavior set by the programmer
  666. X       is    used.  If the programmer has not explicitly used
  667. ***************
  668. *** 627,638 ****
  669. X       only a command-line synopsis is printed (this is also
  670. X       refferred to as ``terse'' mode). The other    two ``modes''
  671. X       control the displaying of option syntax and long-option
  672. -      syntax. A mode may    be explicitly disabled by preceding its
  673. -      corresponding string with the `!'    character. The ``modes''
  674. -      which correspond to the possible values of    the ``USAGECNTL''
  675. -      environment variable are given by the following table.
  676. X  
  677. X  
  678. X       Quiet
  679. X        No usage message of any kind is displayed.
  680. X  
  681. --- 651,676 ----
  682. X       only a command-line synopsis is printed (this is also
  683. X       refferred to as ``terse'' mode). The other    two ``modes''
  684. X       control the displaying of option syntax and long-option
  685. X  
  686. X  
  687. + Page 10
  688. + PARSEARGS(1)                         PARSEARGS(1)
  689. +      syntax. A mode may    be explicitly disabled by preceding its
  690. +      corresponding string with the `!'    or `-' character. The
  691. +      ``modes'' which correspond    to the possible    values of the
  692. +      ``USAGECNTL'' environment variable    are given by the
  693. +      following table.
  694. X       Quiet
  695. X        No usage message of any kind is displayed.
  696. X  
  697. ***************
  698. *** 651,670 ****
  699. X       Description
  700. X        The command description is printed.
  701. X  
  702. - Page 10
  703. - PARSEARGS(1)                         PARSEARGS(1)
  704. X       Terse
  705. X        Terse    mode, just print command-line synopsis.
  706. X  
  707. --- 689,694 ----
  708. ***************
  709. *** 680,685 ****
  710. --- 704,710 ----
  711. X       KeyWords
  712. X        Same as LongOpts.
  713. X  
  714. X       If    the environment    variable ``USAGECNTL'' is empty    or
  715. X       undefined,    then the default usage level (which is presently
  716. X       ``Verbose + Options'') will be used.
  717. ***************
  718. *** 689,697 ****
  719. X       specification for a Bourne    shell script:
  720. X  
  721. X       #!/bin/sh
  722. X       RepCount=2;
  723. X       Verbose="";
  724. X       ARGSPEC="
  725. X       'c', ARGOPT,          argInt,  RepCount, 'count    {# times to repeat}',
  726. X       'v', ARGOPT,          argBool, Verbose,     'verbose {turn    on verbose mode}',
  727. --- 714,736 ----
  728. X       specification for a Bourne    shell script:
  729. X  
  730. X       #!/bin/sh
  731. X       RepCount=2;
  732. X       Verbose="";
  733. + Page 11
  734. + PARSEARGS(1)                         PARSEARGS(1)
  735. X       ARGSPEC="
  736. X       'c', ARGOPT,          argInt,  RepCount, 'count    {# times to repeat}',
  737. X       'v', ARGOPT,          argBool, Verbose,     'verbose {turn    on verbose mode}',
  738. ***************
  739. *** 701,708 ****
  740. X       ' ', ARGOPT|ARGLIST, listStr, Files,     'files    {files to process}',
  741. X       ENDOFARGS
  742. X       "
  743. X  
  744. -      eval `echo    "$ARGUMENTS" | parseargs -s sh -- $0 "$@"`
  745. X  
  746. X       This describes a Bourne shell script accepting up to three
  747. X       flag arguments and    one or two positional arguments, plus a
  748. --- 740,747 ----
  749. X       ' ', ARGOPT|ARGLIST, listStr, Files,     'files    {files to process}',
  750. X       ENDOFARGS
  751. X       "
  752. +      eval `echo    "$ARGSPEC" | parseargs -s sh --    $0 "$@"`
  753. X  
  754. X  
  755. X       This describes a Bourne shell script accepting up to three
  756. X       flag arguments and    one or two positional arguments, plus a
  757. ***************
  758. *** 717,736 ****
  759. X              FALSE (an empty string).
  760. X  
  761. X        -X        A Boolean ``X Rated'' flag.     This is not
  762. - Page 11
  763. - PARSEARGS(1)                         PARSEARGS(1)
  764. X              printed in the usage message.
  765. X  
  766. X       The two positional    arguments are both strings, as is the
  767. --- 756,761 ----
  768. ***************
  769. *** 758,763 ****
  770. --- 783,802 ----
  771. X       associated    command    line variables,    and then prints    its
  772. X       command usage.
  773. X  
  774. + Page 12
  775. + PARSEARGS(1)                         PARSEARGS(1)
  776. X       #!/bin/sh
  777. X       #      test.sh - Bourne shell script    to test    out the    parseargs command!
  778. X       #
  779. ***************
  780. *** 783,802 ****
  781. X  
  782. X       ##    parse command-line and save assignments    in a temporary file ##
  783. X       parseargs -s sh -e    ARGUMENTS -u --    "$NAME"    "$@" >/tmp/tmp$$
  784. - Page 12
  785. - PARSEARGS(1)                         PARSEARGS(1)
  786. X       if    [ $? -ne 0 ]
  787. X         then rm -f /tmp/tmp$$; exit 2  ## non-zero status (usage    given)
  788. X       fi
  789. --- 822,827 ----
  790. ***************
  791. *** 825,838 ****
  792. X       Parseargs may exit    with one of the    following status codes:
  793. X  
  794. X  
  795. X       -1      Some type of system error occurred during execution,
  796. X        causing the program to exit prematurely.
  797. X  
  798. X       0      Normal exit status (no problems were encountered).
  799. X  
  800. !      1      The calling program specified    the -U or the -M option
  801. !       to parseargs,    or specified an    argUsage flag on the
  802. !       command line.     Only the appropriate message is
  803. X        displayed.
  804. X  
  805. X       2      A command line syntax    error was encountered by
  806. --- 850,876 ----
  807. X       Parseargs may exit    with one of the    following status codes:
  808. X  
  809. X  
  810. + Page 13
  811. + PARSEARGS(1)                         PARSEARGS(1)
  812. X       -1      Some type of system error occurred during execution,
  813. X        causing the program to exit prematurely.
  814. X  
  815. X       0      Normal exit status (no problems were encountered).
  816. X  
  817. !      1      The calling program specified    the -#,    the -U or the -M
  818. !       option to parseargs, or specified an argUsage    flag on
  819. !       the command line.  Only the appropriate message is
  820. X        displayed.
  821. X  
  822. X       2      A command line syntax    error was encountered by
  823. ***************
  824. *** 848,868 ****
  825. X       4      A syntax error was encountered in the    argument
  826. X        specification    string that was    specified to parseargs.
  827. X  
  828. - Page 13
  829. - PARSEARGS(1)                         PARSEARGS(1)
  830. X  FILES
  831. X       /usr/local/parseargs.pl
  832. X        This file defines a perl function named parseargs to
  833. --- 886,891 ----
  834. ***************
  835. *** 892,897 ****
  836. --- 915,934 ----
  837. X        -f-arg
  838. X  
  839. X       will properly assign the string ``-arg'' to the option
  840. + Page 14
  841. + PARSEARGS(1)                         PARSEARGS(1)
  842. X       whereas the following:
  843. X        -f -arg
  844. X  
  845. ***************
  846. *** 916,934 ****
  847. X       Hence multiple ``leading dash'' arguments may specified as
  848. X       follows:
  849. X  
  850. - Page 14
  851. - PARSEARGS(1)                         PARSEARGS(1)
  852. X        -f-dash_arg1 -f-dash_arg2  ...
  853. X  
  854. X  BUGS
  855. --- 953,958 ----
  856. ***************
  857. *** 957,962 ****
  858. --- 981,1000 ----
  859. X  
  860. X       Parseargs cannot properly preserve    any newlines in    shell
  861. X       variables if the eval command is used to read its output
  862. + Page 15
  863. + PARSEARGS(1)                         PARSEARGS(1)
  864. X       (this is a    shortcoming of the eval    command, not of
  865. X       parseargs). If the    user is    concerned about    this particular
  866. X       case, then    the user should    redirect the output from
  867. ***************
  868. *** 966,975 ****
  869. X       or    characters following a newline may be lost, in any
  870. X       variables that are    set by parseargs.
  871. X  
  872. -      Parseargs(1) is subject to    the same caveats as parseargs(3).
  873. -      Refer to the CAVEATS section of the parseargs(3) manual
  874. -      page(s) for more information.
  875. X  AUTHOR
  876. X       Brad Appleton  (brad@ssd.csd.harris.com)
  877. X       Harris Computer Systems, Fort Lauderdale, FL USA
  878. --- 1004,1009 ----
  879. ***************
  880. *** 984,990 ****
  881. X  
  882. X  
  883. X  
  884. ! Page 15
  885. X  
  886. X  
  887. X  
  888. --- 1018,1056 ----
  889. X  
  890. X  
  891. X  
  892. ! Page 16
  893. X  
  894. X  
  895. X  
  896. *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parseargs3.txt    Wed Apr 10 09:56:01 1991
  897. --- parseargs3.txt    Mon Apr 15 08:31:33 1991
  898. ***************
  899. *** 6,22 ****
  900. X  
  901. X  
  902. X  NAME
  903. !      parseargs,    usage -    parse command line argument vectors
  904. X  
  905. X  SYNOPSIS
  906. X       #include <parseargs.h>
  907. X  
  908. !      int  parseargs(  char *argv[],  ARGDESC *argd  )
  909. !      int  fparseargs(  FILE *fp,  ARGDESC *argd     )
  910. !      int  lparseargs(  ArgList *argls,    ARGDESC    *argd  )
  911. !      int  sparseargs(  char *str,  ARGDESC *argd  )
  912. !      int  vparseargs(  ARGDESC *argd, int argc,     ...  )
  913. !      void  usage(  const ARGDESC *argd    )
  914. X  
  915. X  DESCRIPTION
  916. X       Given a vector of string-valued arguments such as that
  917. --- 6,23 ----
  918. X  
  919. X  
  920. X  NAME
  921. !      parseargs - parse command line argument vectors
  922. X  
  923. X  SYNOPSIS
  924. X       #include <parseargs.h>
  925. X  
  926. !      int  parseargs(  char *argv[],  ARGDESC *argd  );
  927. !      int  fparseargs(  FILE *fp,  ARGDESC *argd     );
  928. !      int  lparseargs(  ArgList *argls,    ARGDESC    *argd  );
  929. !      int  sparseargs(  char *str,  ARGDESC *argd  );
  930. !      int  vparseargs(  ARGDESC *argd, int argc,     ...  );
  931. !      void  usage(  const ARGDESC *argd    );
  932. !      extern  const char    *ProgName;
  933. X  
  934. X  DESCRIPTION
  935. X       Given a vector of string-valued arguments such as that
  936. ***************
  937. *** 27,50 ****
  938. X       argument values that are syntactically incorrect.
  939. X  
  940. X       Given a readable input stream and an argdesc array, fpar-
  941. !      seargs will parse arguments in a file in much the same
  942. !      manner as parseargs.  A maximum-line length of 255    charac-
  943. !      ters is imposed.  NO ``escaping'' of any kind is performed.
  944. !      Comments of a limited form    are permitted: if the first non-
  945. !      whitespace    character on a line is a '#' (or '!' for VMS)
  946. !      then that entire line is considered a comment and is
  947. !      ignored.  If a value is provided for an argument that is NOT
  948. !      a list or a vector, then the value    MUST be    on the same line
  949. !      as    the argument (in other words, ``-v val'' is fine but
  950. !      ``-v\nval'' is a not).
  951. X  
  952. X       Given an ArgList and an argdesc array, lparseargs will parse
  953. !      arguments in an ArgList in    much the same manner as    par-
  954. !      seargs.
  955. X  
  956. X       Given a single string and an argdesc array, sparseargs will
  957. !      parse arguments from a string in much the same manner as
  958. !      parseargs.     Sparseargs will split the given string    up into    a
  959. X       vector of whitespace separated tokens and then attempt to
  960. X       parse the resultant vector    as if it were given as argv[] on
  961. X       the command-line.    NO special treatment is    given to charac-
  962. --- 28,50 ----
  963. X       argument values that are syntactically incorrect.
  964. X  
  965. X       Given a readable input stream and an argdesc array, fpar-
  966. !      seargs will parse arguments in a file in the same manner as
  967. !      parseargs.     A maximum-line    length of 255 characters is
  968. !      imposed.  NO ``escaping'' of any kind is performed. Comments
  969. !      of    a limited form are permitted: if the first non-whitespace
  970. !      character on a line is a '#' (or '!' for VMS) then    that
  971. !      entire line is considered a comment and is    ignored.  If a
  972. !      value is provided for an argument that is NOT a list or a
  973. !      vector, then the value MUST be on the same    line as    the argu-
  974. !      ment (in other words, ``-v    val'' is fine but ``-v\nval'' is
  975. !      a not).
  976. X  
  977. X       Given an ArgList and an argdesc array, lparseargs will parse
  978. !      arguments in an ArgList in    the same manner    as parseargs.
  979. X  
  980. X       Given a single string and an argdesc array, sparseargs will
  981. !      parse arguments from a string in much the manner as par-
  982. !      seargs.  Sparseargs will split the    given string up    into a
  983. X       vector of whitespace separated tokens and then attempt to
  984. X       parse the resultant vector    as if it were given as argv[] on
  985. X       the command-line.    NO special treatment is    given to charac-
  986. ***************
  987. *** 52,62 ****
  988. X       Sparseargs    will always assume that    any whitespace characters
  989. X       are intended as argument separators.
  990. X  
  991. X       Vparseargs    takes an argdesc array,    the number of arguments
  992. X       to    parse, and a (possibly NULL terminated)    list of
  993. !      argument-strings and parses them in much the same manner as
  994. !      parseargs.     Unlike    sparseargs, vparseargs assumes that all
  995. X  
  996. X  
  997. X  
  998. --- 52,62 ----
  999. X       Sparseargs    will always assume that    any whitespace characters
  1000. X       are intended as argument separators.
  1001. X  
  1002. X       Vparseargs    takes an argdesc array,    the number of arguments
  1003. X       to    parse, and a (possibly NULL terminated)    list of
  1004. !      argument-strings and parses them in the same manner as par-
  1005. !      seargs.  Unlike sparseargs, vparseargs assumes that all
  1006. !      parameters    are already split up into tokens, hence    any
  1007. X  
  1008. X  
  1009. X  
  1010. ***************
  1011. *** 71,86 ****
  1012. X  
  1013. X  
  1014. X  
  1015. !      parameters    are already split up into tokens, hence    any whi-
  1016. !      tespace characters    contained in any of the    string-parameters
  1017. !      are used as is (and will be considered a part of an argument
  1018. !      name or value).
  1019. X  
  1020. X       Given an argdesc array, usage will    print the usage    for the
  1021. X       given command in the format specified by the user's
  1022. X       USAGECNTL environment variable.
  1023. X  
  1024. X  THE ARGUMENT STRUCTURE
  1025. X       The basic type used by the    parseargs library is the argument
  1026. X       descriptor    (or "argdesc" for short). An ARGDESC structure is
  1027. --- 71,90 ----
  1028. X  
  1029. X  
  1030. X  
  1031. !      whitespace    characters contained in    any of the string-
  1032. !      parameters    are used as is (and will be considered a part of
  1033. !      an    argument name or value).
  1034. X  
  1035. X       Given an argdesc array, usage will    print the usage    for the
  1036. X       given command in the format specified by the user's
  1037. X       USAGECNTL environment variable.
  1038. X  
  1039. +      After returning from any of the aforementioned functions,
  1040. +      the global    string ProgName    will contain the name of the com-
  1041. +      mand corresponding    to the argument-descriptor array that was
  1042. +      most recently operated upon by one    the functions in the par-
  1043. +      seargs(3) function    library.
  1044. X  THE ARGUMENT STRUCTURE
  1045. X       The basic type used by the    parseargs library is the argument
  1046. X       descriptor    (or "argdesc" for short). An ARGDESC structure is
  1047. ***************
  1048. *** 120,131 ****
  1049. X        this field must correspond to    the name of one    of the
  1050. X        argument type    functions described in argtype(3).
  1051. X  
  1052. -      ARBPTR  ad_valp;
  1053. -       This field is    a generic pointer to the storage used to
  1054. -       represent the    internal value of the command-line
  1055. X  
  1056. X  
  1057. X  Page 2
  1058. X  
  1059. X  
  1060. --- 124,131 ----
  1061. ***************
  1062. *** 137,149 ****
  1063. X  
  1064. X  
  1065. X  
  1066. !       argument. It may be a    pointer    to a number, a boolean
  1067. !       value, a string, a list, or anything else for    which
  1068. !       there    exists a corresponding arg-type    function to use
  1069. !       in the ad_type field.    In the case of of parseargs(1)
  1070. !       this field must be the name of the corresponding shell
  1071. !       variable which will eventually hold the value    of the
  1072. !       argument given on the    command-line.
  1073. X  
  1074. X       const char     *ad_prompt;
  1075. X        This field contains the long-name of the argument and
  1076. --- 137,152 ----
  1077. X  
  1078. X  
  1079. X  
  1080. !      ARBPTR  ad_valp;
  1081. !       This field is    a generic pointer to the storage used to
  1082. !       represent the    internal value of the command-line argu-
  1083. !       ment.    It may be a pointer to a number, a boolean value,
  1084. !       a string, a list, or anything    else for which there
  1085. !       exists a corresponding arg-type function to use in the
  1086. !       ad_type field. In the    case of    of parseargs(1)    this
  1087. !       field    must be    the name of the    corresponding shell vari-
  1088. !       able which will eventually hold the value of the argu-
  1089. !       ment given on    the command-line.
  1090. X  
  1091. X       const char     *ad_prompt;
  1092. X        This field contains the long-name of the argument and
  1093. ***************
  1094. *** 155,161 ****
  1095. X        contains any uppercase characters, then the substring
  1096. X        of long-name consisting of all uppercase characters is
  1097. X        used as the argument keyword and the entire long-name
  1098. !       is used as the name of the argument (if a value my be
  1099. X        supplied). The long-name may be matched by supplying a
  1100. X        unique prefix    of either the argument keyword or the
  1101. X        argument name.
  1102. --- 158,164 ----
  1103. X        contains any uppercase characters, then the substring
  1104. X        of long-name consisting of all uppercase characters is
  1105. X        used as the argument keyword and the entire long-name
  1106. !       is used as the name of the argument (if a value may be
  1107. X        supplied). The long-name may be matched by supplying a
  1108. X        unique prefix    of either the argument keyword or the
  1109. X        argument name.
  1110. ***************
  1111. *** 173,179 ****
  1112. X         char *InFile;
  1113. X         char *OutFile =       CHARNULL;
  1114. X         BOOL XRated =  FALSE;
  1115. !        struct namelist *Files =    NULL;
  1116. X  
  1117. X         ARGDESC Args[] =
  1118. X         {
  1119. --- 176,182 ----
  1120. X         char *InFile;
  1121. X         char *OutFile =       CHARNULL;
  1122. X         BOOL XRated =  FALSE;
  1123. !        ArgList *Files =       ARGLISTNULL;
  1124. X  
  1125. X         ARGDESC Args[] =
  1126. X         {
  1127. ***************
  1128. *** 183,197 ****
  1129. X       ' ', ARGREQ,     argStr,  __ &InFile,    "INPUTfile {input file}",
  1130. X       ' ', ARGOPT,     argStr,  __ &OutFile,    "OUTPUTfile {output file}",
  1131. X       'X', ARGHIDDEN, argBool, __ &XRated,    "XratedMODE {naughty stuff!}",
  1132. !      ' ', ARGOPT|ARGLIST, argStr, __ &Files, "File {files to be read}",
  1133. X       ENDOFARGS
  1134. X         };
  1135. X  
  1136. X  
  1137. X  
  1138. X  Page 3
  1139. X  
  1140. X  
  1141. --- 186,197 ----
  1142. X       ' ', ARGREQ,     argStr,  __ &InFile,    "INPUTfile {input file}",
  1143. X       ' ', ARGOPT,     argStr,  __ &OutFile,    "OUTPUTfile {output file}",
  1144. X       'X', ARGHIDDEN, argBool, __ &XRated,    "XratedMODE {naughty stuff!}",
  1145. !      ' ', ARGLIST,     listStr, __ &Files,    "File {files to    be read}",
  1146. X       ENDOFARGS
  1147. X         };
  1148. X  
  1149. X  
  1150. X  
  1151. X  Page 3
  1152. X  
  1153. X  
  1154. ***************
  1155. *** 379,386 ****
  1156. X       arg_sdesc(ad)
  1157. X        Return the description of an argument. If a description
  1158. X        was supplied,    the ARGDESCRIBED flag will be set and the
  1159. !       description will immediately follow the terminating NUL
  1160. !       byte of the string name.
  1161. X  
  1162. X       ARG_isDESCRIBED(ad)
  1163. X        Evaluates to TRUE only if an argument    description was
  1164. --- 379,386 ----
  1165. X       arg_sdesc(ad)
  1166. X        Return the description of an argument. If a description
  1167. X        was supplied,    the ARGDESCRIBED flag will be set and the
  1168. !       description will immediately follow the terminating
  1169. !       NULL byte of the string name.
  1170. X  
  1171. X       ARG_isDESCRIBED(ad)
  1172. X        Evaluates to TRUE only if an argument    description was
  1173. ***************
  1174. *** 448,454 ****
  1175. X        usage    messages.
  1176. X  
  1177. X  CMD MACROS
  1178. !      Parseargs.h defines a set of macros to allow a more "self
  1179. X       documenting" approach to declaring    argument-descriptor
  1180. X       arrays. The "old-style" is    still accepted (but if used it is
  1181. X       recommended that the STARTOFARGS macro is used in conjunc-
  1182. --- 448,454 ----
  1183. X        usage    messages.
  1184. X  
  1185. X  CMD MACROS
  1186. !      <parseargs.h> defines a set of macros to allow a more "self
  1187. X       documenting" approach to declaring    argument-descriptor
  1188. X       arrays. The "old-style" is    still accepted (but if used it is
  1189. X       recommended that the STARTOFARGS macro is used in conjunc-
  1190. ***************
  1191. *** 606,625 ****
  1192. X       Ignore
  1193. X        Ignore any unrecognized or improperly    specified
  1194. X        command-line arguments and continue execution    of the
  1195. !       program. Normally, if    an argument is unmatched (or is
  1196. !       improperly specified), a usage message is printed and
  1197. !       program execution is terminated.
  1198. X  
  1199. X       OptsOnly
  1200. X        Under    UNIX, setting this flag    will disable the parsing
  1201. X        of long-option syntax. This will cause all arguments
  1202. !       starting with    '+' to always be treated as a positional
  1203. X        parameter (instead of    a long-option).
  1204. X  
  1205. X       KwdsOnly
  1206. X        Under    UNIX, setting this flag    disables the parsing of
  1207. X        single-character options.  This will cause all argu-
  1208. !       ments    starting with '-' to always be treated as a posi-
  1209. X        tional parameter (instead of an option).
  1210. X  
  1211. X       LoptsOnly
  1212. --- 606,625 ----
  1213. X       Ignore
  1214. X        Ignore any unrecognized or improperly    specified
  1215. X        command-line arguments and continue execution    of the
  1216. !       program. Normally, if    a required argument is unmatched
  1217. !       (or an argument is improperly    specified), a usage mes-
  1218. !       sage is printed program execution is terminated.
  1219. X  
  1220. X       OptsOnly
  1221. X        Under    UNIX, setting this flag    will disable the parsing
  1222. X        of long-option syntax. This will cause all arguments
  1223. !       starting with    `+' to always be treated as a positional
  1224. X        parameter (instead of    a long-option).
  1225. X  
  1226. X       KwdsOnly
  1227. X        Under    UNIX, setting this flag    disables the parsing of
  1228. X        single-character options.  This will cause all argu-
  1229. !       ments    starting with `-' to always be treated as a posi-
  1230. X        tional parameter (instead of an option).
  1231. X  
  1232. X       LoptsOnly
  1233. ***************
  1234. *** 640,648 ****
  1235. X        positional argument.
  1236. X  
  1237. X       CaseIgnore
  1238. !       Setting this flag causes character-case to be    ignored
  1239. !       when attempting to match single-character argument
  1240. !       names    (i.e. causes "-i" and "-I" will    be considered
  1241. X        equivalent).
  1242. X  
  1243. X       If    the environment    variable ``PARSECNTL'' is empty    or unde-
  1244. --- 640,648 ----
  1245. X        positional argument.
  1246. X  
  1247. X       CaseIgnore
  1248. !       Setting this flag will cause character-case to be
  1249. !       ignored when attempting to match single-character argu-
  1250. !       ment names (i.e. causes "-i" and "-I"    to be considered
  1251. X        equivalent).
  1252. X  
  1253. X       If    the environment    variable ``PARSECNTL'' is empty    or unde-
  1254. ***************
  1255. *** 683,691 ****
  1256. X       ferred to as ``terse'' mode). The other two ``modes'' con-
  1257. X       trol the displaying of option syntax and long-option syntax.
  1258. X       A mode may    be explicitly disabled by preceding its
  1259. !      corresponding string with the `!'    character. The ``modes''
  1260. !      which correspond to the possible values of    the ``USAGECNTL''
  1261. !      environment variable are given by the following table.
  1262. X  
  1263. X       Quiet
  1264. X        No usage message of any kind is displayed.
  1265. --- 683,692 ----
  1266. X       ferred to as ``terse'' mode). The other two ``modes'' con-
  1267. X       trol the displaying of option syntax and long-option syntax.
  1268. X       A mode may    be explicitly disabled by preceding its
  1269. !      corresponding string with the `!'    or `-' character. The
  1270. !      ``modes'' which correspond    to the possible    values of the
  1271. !      ``USAGECNTL'' environment variable    are given by the follow-
  1272. !      ing table.
  1273. X  
  1274. X       Quiet
  1275. X        No usage message of any kind is displayed.
  1276. ***************
  1277. *** 719,725 ****
  1278. X  
  1279. X  
  1280. X  
  1281. X  Page 11
  1282. X  
  1283. X  
  1284. --- 720,725 ----
  1285. ***************
  1286. *** 759,766 ****
  1287. X       vectors however need a set    of flags for each item they con-
  1288. X       tain. Once    an arg-list has    been created, it may be    deallo-
  1289. X       cated using the function listFree.    ListFree takes one param-
  1290. !      eter: first of which is the address of the    first item in the
  1291. !      arg-list.
  1292. X  
  1293. X       An    alternative to argument-lists is argument vectors (or
  1294. X       arg-vectors).  Arg-vectors    use the    ARGVEC flag instead of
  1295. --- 759,765 ----
  1296. X       vectors however need a set    of flags for each item they con-
  1297. X       tain. Once    an arg-list has    been created, it may be    deallo-
  1298. X       cated using the function listFree.    ListFree takes one param-
  1299. !      eter: the address of the first item in the    arg-list.
  1300. X  
  1301. X       An    alternative to argument-lists is argument vectors (or
  1302. X       arg-vectors).  Arg-vectors    use the    ARGVEC flag instead of
  1303. ***************
  1304. *** 769,775 ****
  1305. X       responsible for handling vectors of its type (although some
  1306. X       argXxx functions such as the boolean types    do not support
  1307. X       vectors). An arg-vector is    a structure which contains a
  1308. !      count, an array of    elements (i.e. an argc/argv pair), and an
  1309. X       array of flags, one for each element of argv. There are two
  1310. X       macros in defined in <parseargs.h>    which are used for arg-
  1311. X       vectors. ARGVEC_T may be used to declare a    vector structure
  1312. --- 768,774 ----
  1313. X       responsible for handling vectors of its type (although some
  1314. X       argXxx functions such as the boolean types    do not support
  1315. X       vectors). An arg-vector is    a structure which contains a
  1316. !      count, an array of    elements (i.e. an argc,argv pair), and an
  1317. X       array of flags, one for each element of argv. There are two
  1318. X       macros in defined in <parseargs.h>    which are used for arg-
  1319. X       vectors. ARGVEC_T may be used to declare a    vector structure
  1320. ***************
  1321. *** 783,788 ****
  1322. --- 782,788 ----
  1323. X  
  1324. X        ( StrVec.array[ StrVec.count ] == (char *)NULL )
  1325. X  
  1326. +      is    always true, and character-vectors will    always have an
  1327. X  
  1328. X  
  1329. X  
  1330. ***************
  1331. *** 797,803 ****
  1332. X  
  1333. X  
  1334. X  
  1335. -      is    always true, and character-vectors will    always have an
  1336. X       extra NUL-character at the    end such that:
  1337. X  
  1338. X        ( CharVec.array[ CharVec.count ] == '\0' )
  1339. --- 797,802 ----
  1340. ***************
  1341. *** 849,854 ****
  1342. --- 848,854 ----
  1343. X          printf(    "String[%d]=%s,    flags=%x\n",
  1344. X              i, StrVec.array[i], StrVec.flags[i] );
  1345. X  
  1346. +          for ( i = 0 ; i < NumVec.count ; i++ )
  1347. X  
  1348. X  
  1349. X  
  1350. ***************
  1351. *** 863,869 ****
  1352. X  
  1353. X  
  1354. X  
  1355. -          for ( i = 0 ; i < NumVec.count ; i++ )
  1356. X          printf(    "Number[%d]=%s,    flags=%x\n",
  1357. X              i, NumVec.array[i], NumVec.flags[i] );
  1358. X  
  1359. --- 863,868 ----
  1360. ***************
  1361. *** 884,901 ****
  1362. X  
  1363. X        BOOL    argXxx(     ARGDESC *ad,  char *vp,  BOOL copyf  )
  1364. X  
  1365. !      The argd argument points to the descriptor    for the    argument
  1366. !      being converted.  Its main    use is to find the location in
  1367. !      which to store the    converted value, located in
  1368. !      argd->ad_valp.  The string    value to be converted is passed
  1369. !      in    vp (which will be NULL if the ARGNOVAL flag was    set for
  1370. !      the corresponding entry in    the arg-descriptor table).  The
  1371. !      copyf flag    is TRUE    if the vp string value must be copied
  1372. !      when saved.  Most non-string types    are copied implicitly
  1373. !      (for example, integer arguments are stored    in binary form,
  1374. !      so    the original string value need not be saved), so this
  1375. !      argument can usually be ignored.  Put simply, this    flag is
  1376. !      TRUE when vp points to a temporary    buffer area.
  1377. X  
  1378. X       If    the type function successfully converts    the value, and
  1379. X       uses the entire value, it should return TRUE.  If the type
  1380. --- 883,900 ----
  1381. X  
  1382. X        BOOL    argXxx(     ARGDESC *ad,  char *vp,  BOOL copyf  )
  1383. X  
  1384. !      The ad argument points to the descriptor for the argument
  1385. !      being converted. Its main use is to find the location in
  1386. !      which to store the    converted value, located in ad->ad_valp.
  1387. !      The string    value to be converted is passed    in vp (which will
  1388. !      be    NULL if    the ARGNOVAL flag was set for the corresponding
  1389. !      entry in the arg-descriptor table).  The copyf flag is TRUE
  1390. !      if    the vp string value must be copied when    saved.    Most
  1391. SHAR_EOF
  1392. true || echo 'restore of DOCPATCH failed'
  1393. echo 'End of  part 1'
  1394. echo 'File DOCPATCH is continued in part 2'
  1395. echo 2 > _shar_seq_.tmp
  1396. exit 0
  1397. exit 0 # Just in case...
  1398. -- 
  1399. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1400. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1401. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1402. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1403.